<template>
  <div class="oper_reco">
  		<crud-form
	      :field-list="fieldList"
	      :exportFn="exportFn"
	      :api="getSystemLog"
	      :queryParam="formInline"
	      :columnNum="'9'"
	      ref="crudForm"
	      :showColumnHandle="false"
	    >
	      <template slot="searchBar">
	      	 <el-form size="mini" :inline="true"  ref="refform" class="ref_form">
		      <el-form-item label="日志类型" class="a">
		        <el-select size="mini" v-model="formInline.logType" placeholder="全部" class="xzk" clearable>
		          <el-option
		            v-for="item in busType"
		            :key="item.value"
		            :value="item.value"
		            :label="item.name"
		          ></el-option>
		        </el-select>
		      </el-form-item>
		
		      <el-form-item label="创建时间">
		        <el-date-picker
		        	clearable
		          v-model="value"
		          type="daterange"
		          range-separator="至"
		          start-placeholder="开始日期"
		          :picker-options="pickerOptions"
		          end-placeholder="结束日期"
		          format="yyyy 年 MM 月 dd 日"
		          value-format="yyyy-MM-dd"
		        ></el-date-picker>
		      </el-form-item>
		      <el-form-item>
		        <el-button @click="search" class="newButtonColor SearchBTN">查询</el-button>
		        <el-button @click="rese" class="otherBTN SearchBTN">清空</el-button>
		      </el-form-item>
		    </el-form>
	      </template>	      
      </crud-form>
  </div>
</template>
<script>
import crudForm from "@/components/crudForm/index";
import { getSystemLog } from "@/api/system/log";
import { DICTDATA, translatorDict, getDict } from "@/api/dict";
import { getRegNameByCode } from "@/utils/area";
import { dateFormat } from "@/utils/DateFormat";

export default {
	name:'system-log',
  components: {
    crudForm
  },
  watch: {
    value(a) {
    	if(a){
    		this.formInline.createdTimeStart = a[0];
      	this.formInline.createdTimeEnd = a[1];
    	}else{
    		this.formInline.createdTimeStart = '';
      	this.formInline.createdTimeEnd = '';
    	}
      
    }
  },
  data() {
  	let statusFormat = (row) => {
      return translatorDict(DICTDATA.SYSTEM_LOGS, Number(row.logType));
    };
  	let dateFormats = (row) => {
      return dateFormat(row.requestTime);
    };
  	let dateFormats_ = (row) => {
      return dateFormat(row.createdTime);
    };
    return {
    //分页
    pageData: {
        total: 0,
        current: 1,
        size: 10,
      },
      fieldList: [
		        { name: "登录账号", value: "loginUser" },
		        { name: "用户名称", value: "loginUser", showOverflowTooltip: true },
		        { name: "id名称", value: "id", showOverflowTooltip: true},
		        { name: "日志类型", value: "logType", formatter:statusFormat},
		        { name: "操作行为", value: "operation", showOverflowTooltip: true,},
		        { name: "请求IP", value: "ip", showOverflowTooltip: true },
		        { name: "请求方法", value: "method", showOverflowTooltip: true },
		        { name: "入网时间", value: "requestTime", showOverflowTooltip: true, formatter:dateFormats },
		        { name: "创建时间", value: "createdTime", showOverflowTooltip: true, formatter:dateFormats_  },
		      ],
      tableData: [],
      formInline: {
      	
      },
      busType: [],
      isActive: true,
      value: [],
      siteArr: [],
      getSystemLog,
      pickerOptions: {
	        disabledDate(time) {
	        	return time.getTime() > Date.now();
	        }
	    }
    };
  },

  created() {
    getDict(DICTDATA.SYSTEM_LOGS).then((res) => {
      this.busType = res;
    });
  },
  methods: {
  	search(){
			this.$refs.crudForm.queryParam = this.formInline;
			this.$refs.crudForm.getDataInit()
		},
  	rese(){
  		this.value = [];
  		this.formInline = {};
  	},
    exportFn(){
    	
    },
  }
};
</script>
<style lang="scss" scoped>

</style>